var otopone=document.getElementById("topone");
var otoptwo=document.getElementById("toptwo");
var obottomone=document.getElementById("bottomone");
var obottomtwo=document.getElementById("bottomtwo");
var otoleft1=document.getElementById("toleft1");
var orotate1=document.getElementById("rotate1");
var orotate2=document.getElementById("rotate2");
var otoleft2=document.getElementById("toleft2");
var orotate3=document.getElementById("rotate3");
var otoleft3=document.getElementById("toleft3");
var orotate4=document.getElementById("rotate4");
var otoleft4=document.getElementById("toleft4");
var oimg1=document.getElementById("img1");
var oimg2=document.getElementById("img2");
var oimg3=document.getElementById("img3");
var oimg4=document.getElementById("img4");
var ohand_contro_left=document.getElementById("hand-contro-left");
var ohand_contro_right=document.getElementById("hand-contro-right");
var orobotimg=document.getElementById("robotimg");
var obackgroudimg=document.getElementById("backgroudimg");
var obarvideo=document.getElementById("barvideo");
var osocrepbottom=document.getElementById("socrepbottom");
var ocreattouchtop=document.getElementById("creattouchtop");
var odhchatop=document.getElementById("dhchatop");
var olefthand=document.getElementById("lefthand");
var orighthand=document.getElementById("righthand");
var oshape1=document.getElementById("shape1");
var oshape2=document.getElementById("shape2");
var oshape3=document.getElementById("shape3");
var orobotvideo=document.getElementById("robotvideo")
var sign=0;
var iszhuan=0;

window.onscroll /*=window.document.onresize*/=function(){
   /* var scrtop=document.documentElement.scrollTop||document.body.scrollTop;
     var height=document.documentElement.clientHeight||document.body.clientHeight;*/
    var t = document.body.scrollTop;
    if(t>496){
        odhchatop.style.marginTop="-90px";
        odhchatop.style.transition="all 0.4s";
    }
    if(t>1050&&t<1700){
        osocrepbottom.style.marginTop="0";
        osocrepbottom.style.transition="all 0.7s";
    }
    if(t>1900){
        otopone.style.marginTop="0px";
        otopone.style.opacity="1";
        otopone.style.transition="all 0.3s";
        otoptwo.style.marginTop="0px";
        otoptwo.style.opacity="1";
        otoptwo.style.transition="all 0.6s"

    }
    if(t>2400){
        obottomone.style.marginTop="0px";
        obottomone.style.opacity="1";
        obottomone.style.transition="all 0.3s";
        obottomtwo.style.marginTop="0px";
        obottomtwo.style.opacity="1";
        obottomtwo.style.transition="all 0.6s"
    }
    if( t>1560&& t<2290){
        d=0;
        zhuan45();
    }
    if(t>2800&&t<3100){
        ocreattouchtop.style.marginTop="0";
        ocreattouchtop.style.transition="all 0.7s"
    }
    if(t>450&&t<1477)
    {//顶部第一个特效
        if (t > sign) {
            sign = t;
           /* console.log("向下" + t);*/
            olefthand.style.marginLeft = "-270px";
            olefthand.style.transition = "all 7s";
            orighthand.style.marginTop = "-280px";
            orighthand.style.transition = "all 5s";
            orighthand.style.marginLeft = "110px";
            oshape1.style.marginTop="-129px";
            oshape1.style.transition="all 5s";
            oshape2.style.marginTop="-30px";
            oshape2.style.transition="all 5s";
            oshape3.style.marginTop="103px";
            oshape3.style.transition="all 5s"
        }
        if (t < sign) {
            sign = t;
            console.log("向上" + t);
            olefthand.style.marginLeft = "-400px";
            olefthand.style.transition = "all 7s";
            orighthand.style.marginTop = "-260px";
            orighthand.style.transition = "all 4s";
            orighthand.style.marginLeft = "10px";
            oshape1.style.marginTop="-154px";
            oshape1.style.transition="all 5s";
            oshape2.style.marginTop="-93px";
            oshape2.style.transition="all 5s";
            oshape3.style.marginTop="-46px";
            oshape3.style.transition="all 5s"
        }

    }
};
function zhuan45(){
    if(!iszhuan){
        d+=3;
        ohand_contro_left.style.transform = 'rotate(' + d + "deg)";
        ohand_contro_right.style.transform = 'rotate(' + d + "deg)";
        if(d<=45)setTimeout(zhuan45,30);
        else iszhuan=1;
    }

}
/*机器人/手枪移动、握手柄特效*/
function mouseCoords(ev)//获取鼠标的x/y位置
{
    /* if(ev.pageX || ev.pageY){
     return {x:ev.pageX, y:ev.pageY};
     }*/
    return{
        x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
        y:ev.clientY + document.body.scrollTop - document.body.clientTop
    };
}
document.onmousemove = mouseMove;//等于document.body.onmousemove=mouseMove;
function mouseMove(ev)
{
    var s = document.body.scrollTop;
    /*Ev= ev || window.event;*/
    var mousePos = mouseCoords(ev);//鼠标坐标

    //console.log(s);
    if(s>3325&&s<4000&&mousePos.x>=675) {
        obarvideo.style.transform = 'rotate(' +(((-675)+(mousePos.x))*(0.005))+ "deg)";
    }
    if(s>3325&s<4000&&mousePos.x<675){
        obarvideo.style.transform = 'rotate(' +(((-675)+(mousePos.x))*(0.005) )+ "deg)";
    }
    /*console.log("top"+s);*/
    if( s>3325&& s<400){
        ohand_contro_left.style.transition="";
        ohand_contro_right.style.transition="";
        if(mousePos.x>675){
            ohand_contro_left.style.transform = 'rotate(' +(((-675)+(mousePos.x))*(0.09))+ "deg)";
            ohand_contro_right.style.transform = 'rotate(' +(((-675)+(mousePos.x))*(0.09))+ "deg)";
        }
        if(mousePos.x<=675){
            ohand_contro_left.style.transform = 'rotate(' +(((-675)+(mousePos.x))*(0.03))+ "deg)";
            ohand_contro_right.style.transform = 'rotate(' +(((-675)+(mousePos.x))*(0.03))+ "deg)";
        }
    }

    if(s>3325&&s<4000){
        orobotimg.style.left=41+"%"+(mousePos.x)/10+"px";
        orobotimg.style.top=(mousePos.y)/20-270+"px";
        obackgroudimg.style.left=(mousePos.x)/50-50+"px";
    }
}

/*console.log(window.scrollY);*/
orotate1.onmouseout=function(){
    otoleft1.style.marginLeft="10px";
    otoleft1.style.transition="all 2s";
};
orotate1.onmouseover=function(){
    otoleft1.style.marginLeft="-100px";
    otoleft1.style.transition="all 2s";
};
orotate2.onmouseout=function(){
    otoleft2.style.marginLeft="10px";
    otoleft1.style.transition="all 2s";
};
orotate2.onmouseover=function(){
    otoleft2.style.marginLeft="-110px";
    otoleft2.style.transition="all 2s";
};
orotate3.onmouseout=function(){
    otoleft3.style.marginLeft="10px";
    otoleft3.style.transition="all 2s";
};
orotate3.onmouseover=function(){
    otoleft3.style.marginLeft="-63px";
    otoleft3.style.transition="all 2s";
};
orotate4.onmouseout=function(){
    otoleft4.style.marginLeft="10px";
    otoleft4.style.transition="all 2s";
};
orotate4.onmouseover=function(){
    otoleft4.style.marginLeft="-110px";
    otoleft4.style.transition="all 2s";
};
oimg1.onmouseout=function(){
    oimg1.style.transform.scale="1,1";
    oimg1.style.transition="all 10s"
};
oimg2.onmouseout=function(){
    oimg2.style.transform.scale="1,1";
    oimg2.style.transition="all 10s"
};
oimg3.onmouseout=function(){
    oimg3.style.transform.scale="1,1";
    oimg3.style.transition="all 10s"
};
oimg4.onmouseout=function(){
    oimg4.style.transform.scale="1,1";
    oimg4.style.transition="all 10s"
};


